package edu.visualizetion.info.sensorcollection;

import java.io.File;
import java.io.FileNotFoundException;

public class ClassPathUtils {

	public void addLibToClassPath(String resource) throws FileNotFoundException {
		/*
		 * 获得lib下的所有文件
		 */
		File file = new File(resource);
		resource = file.getAbsolutePath();
		if (!file.exists()) {
			throw new FileNotFoundException("the class path resource file is not found");
		}
		String path = System.getProperty("java.library.path");
		if (isWinOS()) {
			path = resource + ";" + path;
		} else {
			path = resource + ":" + path;
		}
		System.setProperty("java.library.path", path);
		path = System.getProperty("java.library.path");
	}

	private boolean isWinOS() {
		String osType = System.getProperty("os.name").toLowerCase();
		if (osType.indexOf("win") >= 0) {
			return true;
		} else {
			return false;
		}
	}
}
